package dk.hewison.client.domain;

import java.io.Serializable;

/**
 * @author John Hewison
 * @author $LastChangedBy: john.hewison $:  $ $LastChangedDate: 2009-02-07 20:27:07 +0000 (Sat, 07 Feb 2009) $:
 * @version $Revision: 362 $:
 */
public class Photo implements Serializable {

    String folderName;

    String fileName;
    String actualFileName;

    String thumbnailFileName;
    String name;

    String caption;
    String description;


    public Photo(String folderName, String fileName) {
        //todo switch this later
        this.folderName = folderName;
        this.actualFileName = fileName;

        this.name = fileName.toLowerCase();

        this.fileName = ".a" + name;
        this.thumbnailFileName = "." + name;


    }

    public String getFileNameUrl() {
        return folderName + "/" + fileName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCaption() {
        return caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getThumbnailUrl() {
        return folderName + "/" + thumbnailFileName;
    }

    public void setThumbnailFileName(String thumbnailFileName) {
        this.thumbnailFileName = thumbnailFileName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Photo photo = (Photo) o;

        if (fileName != null ? !fileName.equals(photo.fileName) : photo.fileName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = fileName != null ? fileName.hashCode() : 0;
        result = 31 * result + (thumbnailFileName != null ? thumbnailFileName.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (caption != null ? caption.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Photo{" +
                "fileName='" + fileName + '\'' +
                ", thumbnailFileName='" + thumbnailFileName + '\'' +
                ", name='" + name + '\'' +
                ", caption='" + caption + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}
